* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', sans-serif;
}

body {
    background-color: #f5f5f5;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.container {
    width: 100%;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* 登录界面样式 */
.login-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f5f5f5;
}

.login-box {
    width: 400px;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.login-box h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    color: #666;
}

.input-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.btn {
    width: 100%;
    padding: 12px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #45a049;
}

.error-message {
    color: #f44336;
    margin-top: 10px;
    text-align: center;
}

/* 聊天界面样式 */
.chat-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-radius: 0;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background-color: #07c160;
    color: white;
    height: 60px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.chat-header h2 {
    flex: 1;
    font-size: 18px;
    font-weight: 500;
}

.chat-header #currentUser {
    margin-right: 15px;
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 14px;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

.btn-clear {
    background-color: #ff9800;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-clear:hover {
    background-color: #f57c00;
}

.btn-logout {
    padding: 8px 15px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-logout:hover {
    background-color: #d32f2f;
}

.chat-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.left-sidebar {
    width: 280px;
    background-color: #ededed; /* 微信风格灰色背景 */
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.user-list {
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.user-list h3 {
    margin: 0;
    padding: 12px 15px;
    color: #333; /* 深色文字 */
    text-align: left;
    font-weight: 500;
    font-size: 16px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #ededed;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-list h3 #onlineCount {
    font-size: 14px;
    color: #666;
    font-weight: normal;
}

.user-list ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}

.user-list li {
    padding: 12px 15px;
    background-color: #ededed;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: #333;
    font-weight: normal;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
    height: 70px;
}

.user-list li .user-name {
    flex: 1;
    font-size: 16px;
    margin-left: 60px; /* 为头像留出空间 */
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-top: 5px;
}

.user-list li .last-time {
    position: absolute;
    top: 12px;
    right: 15px;
    font-size: 12px;
    color: #999;
}

.user-list li .unread-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: #f44336;
    color: white;
    font-size: 12px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.user-list li:before {
    content: '';
    position: absolute;
    left: 15px;
    top: 15px;
    display: inline-block;
    width: 45px;
    height: 45px;
    background-color: #07c160;
    border-radius: 4px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>');
    background-size: 30px;
    background-position: center;
    background-repeat: no-repeat;
}

.user-list li:hover {
    background-color: #e5e5e5;
}

.user-list li.active {
    background-color: #c9c9c9;
    font-weight: normal;
}

.user-list li.message-highlight {
    animation: highlight-pulse 2s ease-in-out;
    background-color: #e5e5e5;
}

.user-list li.message-highlight:after {
    content: '';
    position: absolute;
    right: 15px;
    top: 15px;
    width: 8px;
    height: 8px;
    background-color: #f44336;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(244, 67, 54, 0.5);
}

.user-list li.message-sent {
    animation: sent-pulse 1s ease-in-out;
    background-color: #e5e5e5;
}

.user-list li.message-sent:after {
    content: '已发送';
    position: absolute;
    right: 15px;
    bottom: 15px;
    font-size: 12px;
    color: #07c160;
    background-color: rgba(7, 193, 96, 0.1);
    padding: 2px 6px;
    border-radius: 10px;
}

@keyframes highlight-pulse {
    0% { background-color: #fff; }
    50% { background-color: #f0f0f0; }
    100% { background-color: #fff; }
}

@keyframes sent-pulse {
    0% { background-color: #fff; }
    50% { background-color: #f0f0f0; }
    100% { background-color: #fff; }
}

.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #ebebeb;
}

.message-container {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #ebebeb;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><rect width="20" height="20" fill="%23ebebeb"/><circle cx="10" cy="10" r="1" fill="%23e0e0e0"/></svg>');
    background-size: 20px 20px;
}

.message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 85%;
}

.message-info {
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.timestamp {
    color: #aaa;
    font-style: normal;
    font-size: 11px;
}

.direction {
    color: #aaa;
    font-size: 11px;
}

/* 历史消息分隔线样式 */
.history-separator {
    text-align: center;
    margin: 15px 0;
    position: relative;
    color: #888;
}

.history-separator hr {
    position: absolute;
    top: 50%;
    width: 100%;
    margin: 0;
    border: none;
    border-top: 1px dashed #ccc;
    z-index: 1;
}

.history-separator span {
    display: inline-block;
    padding: 0 10px;
    background-color: #f5f5f5;
    position: relative;
    z-index: 2;
    font-size: 12px;
}

.message-info .timestamp {
    margin-right: 5px;
    font-weight: bold;
}

.message-info .direction {
    color: #aaa;
    margin: 0 3px;
}

.message-bubble {
    max-width: 100%;
    padding: 10px 15px;
    border-radius: 4px;
    word-break: break-word;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
}

.message.received {
    align-items: flex-start;
    margin-right: auto;
}

.message.sent {
    align-items: flex-end;
    margin-left: auto;
}

.message.received .message-bubble {
    background-color: #fff;
    border-radius: 4px 4px 4px 0;
}

.message.received .message-bubble:before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-right: 8px solid #fff;
    border-top: 8px solid transparent;
    border-bottom: 8px solid #fff;
}

.message.sent .message-bubble {
    background-color: #95ec69;
    color: #000;
    border-radius: 4px 4px 0 4px;
}

.message.sent .message-bubble:before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid #95ec69;
    border-top: 8px solid transparent;
    border-bottom: 8px solid #95ec69;
}

/* 添加用户颜色样式 */
.message.received .sender {
    font-weight: bold;
    color: #2196F3; /* 蓝色 */
}

.message.sent .sender {
    font-weight: bold;
    color: #4CAF50; /* 绿色 */
}

.message .receiver {
    font-weight: bold;
    color: #9C27B0; /* 紫色 */
}

.message .broadcast-receiver {
    color: #FF5722; /* 橙红色 */
}

/* 群发消息样式 */
.message.broadcast .message-bubble {
    background-color: #fff8e1; /* 浅黄色背景 */
}

.message.sent.broadcast .message-bubble {
    background-color: #fff3e0; /* 浅橙色背景 */
}

.message.system {
    text-align: center;
    margin: 10px 0;
}

.message.system .message-bubble {
    background-color: #f1f1f1;
    color: #666;
    display: inline-block;
    padding: 5px 10px;
    border-radius: 10px;
    font-size: 12px;
}

.message-input {
    display: flex;
    padding: 10px 15px;
    background-color: #f6f6f6;
    border-top: 1px solid #e0e0e0;
    align-items: center;
    position: relative;
}

.message-input select {
    width: 120px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    margin-right: 10px;
    background-color: #fff;
    font-size: 14px;
    color: #333;
}

.message-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 15px;
    margin-right: 10px;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.btn-send {
    padding: 8px 15px;
    background-color: #07c160;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    min-width: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover {
    background-color: #06b057;
    box-shadow: 0 2px 5px rgba(7, 193, 96, 0.3);
}